var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res) {
  res.render('index', { title: 'Express' });
});

router.get('/hello', function(req, res) {
  res.send('The time is ' + new Date().toString());
});

router.get('/list', function(req, res) {
  res.render('list', {
  title: 'List',
  items: [1991, 'byvoid', 'express', 'Node.js'] });
});

router.get('/reg', function(req, res) {
  res.render('reg', {title: '用户注册'});
});

router.post('/reg', function(req, res) {
	if(req.body['password-repeat'] != req.body['password']){
		req.flash('error', '两次输入的口令不一致');
		return req.redirect('/reg');
	}
});

router.get('/login', function(req, res) {
  res.send('login');
});

router.get('/loginout', function(req, res) {
  res.send('loginout');
});

module.exports = router;

